import { createAndInitilalizeTable } from '@/components/table/lib';
import { ready, assert, getApiPath } from '@/lib/utils.ts';

import {
    IDCol,
    tf,
} from '@/components/table/lib';

function initializeTable(url: string) {
    const table_elem = document.getElementById("table");
    assert(table_elem, "Element with ID 'table' not found");
        
    createAndInitilalizeTable(
        url,
        table_elem,
        {
            columnDefs: [
                IDCol,
                {
                    ...tf("quality_control_report", "质控报告"),
                    width: 150,
                },
                {
                    ...tf("is_confirmed", "质控确认"),
                    width: 120,
                },
                {
                    ...tf("quality_control_cause", "有因质控"),
                    width: 150,
                },
                {
                    ...tf("date_of_inspection", "接受检查日期"),
                    type: 'date',
                },
                {
                    ...tf('inspection_feedback', "接受检查反馈主要问题"),
                    width: 200,
                },
                {
                    ...tf("training_name", "培训名称"),
                    width: 150,
                },
                {
                    ...tf("date_of_training", "培训日期"),
                    type: 'date',
                },
                {
                    ...tf("promotion_meeting", "培训序号"),
                    minWidth: 150,
                    flex: 1,
                }
            ]
        }
    );
}

(function () {
    ready(() => {
        initializeTable(getApiPath());
    });
})();
